package com.tyk.bookstore.back.order.manager.excel.config;

import com.tyk.bookstore.back.common.core.excel.ExcelManager;
import com.tyk.bookstore.back.common.core.model.exception.CustomException;
import com.tyk.bookstore.back.common.core.model.result.CommonResultEnum;
import com.tyk.bookstore.back.order.manager.excel.model.OrderExcelVo;
import com.tyk.bookstore.back.order.repository.OrderRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author tyk
 * @description BookExcelConfig
 */
@Configuration
@RequiredArgsConstructor
public class OrderExcelConfig {
    private final OrderRepository orderRepository;

    @Bean
    public ExcelManager<OrderExcelVo> orderExcelManager() {
        return new ExcelManager<>() {
            @Override
            public void handleSaveException(MultipartFile file, Exception e) {
                throw new CustomException(CommonResultEnum.FILE_OR_DATA_FORMAT_ERROR);
            }
        };
    }

}
